<template>
  <span>
    <svg-icon v-if="flag" icon-class="fullscreen" class="my-icon" @click="toggleScreen" />
    <svg-icon v-else icon-class="exit-fullscreen" class="my-icon" @click="toggleScreen" />
  </span>
</template>

<script>
import ScreenFull from 'screenfull'
export default {
  name: 'Screen',
  data() {
    return {
      flag: true
    }
  },
  methods: {
    toggleScreen() {
      // console.log(ScreenFull.isEnabled)  // 判断浏览器是否之前全屏
      if (ScreenFull.isEnabled) {
        this.flag = !this.flag
        ScreenFull.toggle()
      } else {
        this.$message.warning('您的浏览器版本较低,不支持开启全屏')
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.my-icon{
  fill: #fff;
  font-size: 20px;
  cursor: pointer;
}
</style>
